<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

function contact_list_page()
{
    drupal_add_css(path_to_theme().'/assets/css/css.css', array('type' => 'file'));
    global $user;
    if(!empty($user->uid)) {
        @$output = drupal_render(drupal_get_form('contact_list_form'));
    }else{
        @$output = drupal_render(drupal_get_form('user_login'));
    }
    print $output;
}
function contact_list_form($form, &$form_state){
    global $user;
    if (in_array('农户', $user->roles)) {
        $form['consult']['#markup'] = '<div><a style="text-decoration: none" href="javascript:void(0);" ' .
            "onclick=\"javascript:void window.open('" . base_path() . "contact/service?type=consult','1446518728896', 'width=542,height=670,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;\">开始咨询</a></div>";
        $form['complain']['#markup'] = '<div><a style="text-decoration: none" href="javascript:void(0);" ' .
            "onclick=\"javascript:void window.open('" . base_path() . "contact/service?type=complain','1446518728896', 'width=542,height=670,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0');return false;\">开始投诉</a></div>";
    }else if (in_array('升级成农户', $user->roles) && !in_array('administrator', $user->roles)  && !in_array('销售员', $user->roles)  && !in_array('销售管理员', $user->roles)
        && !in_array('农化服务员', $user->roles) && !in_array('农化管理员', $user->roles) && !in_array('经销商', $user->roles)  && !in_array('农户', $user->roles)  && !in_array('公司领导', $user->roles)) {
        $form['prompt']['#markup']  = '<span>请等待我们验证后开通此功能</span>
            <a onclick="close_win()" style="text-decoration: none;display: block;" ><input type="button" value="OK"  class="close-open"></a>';
    }else if (in_array('anonymous user', $user->roles)) {
        $form['prompt']['#markup']  = '<span>请完成注册开通此功能</span>
            <a onclick="close_win()" style="text-decoration: none;display: block;" ><input type="button" value="OK"  class="close-open"></a>';
    } else if (in_array('authenticated user', $user->roles) && !in_array('administrator', $user->roles)  && !in_array('销售管理员', $user->roles)  && !in_array('销售员', $user->roles)
        && !in_array('农化服务员', $user->roles) && !in_array('农化管理员', $user->roles) && !in_array('经销商', $user->roles)  && !in_array('农户', $user->roles)  && !in_array('公司领导', $user->roles)){
        $form['prompt']['#markup']  = '<span>请完成账户升级开通此功能</span>
            <a onclick="close_win()" style="text-decoration: none;display: block;" ><input type="button" value="OK"  class="close-open"></a>';
    }
    return $form;
}